<?php
class AdminModule extends CWebModule{
	public function init(){
		// this method is called when the module is being created
		// you may place code here to customize the module or the application

		// import the module-level models and components
		$this->setImport(array(
			'admin.models.*',
			'admin.components.*',
		));
        
        
        //这里重写父类里的组件
		//如有需要还可以参考API添加相应组件
		Yii::app()->setComponents(
			array(
				'admin'=>array(
					'class'=>'AdminWebUser',//后台登录类实例
					'stateKeyPrefix'=>'admin',//后台session前缀
					'allowAutoLogin'=>true,
					'loginUrl'=>Yii::app()->createUrl('/admin/default/login'),
				),
                'user'=>array(
					// enable cookie-based authentication
					'allowAutoLogin'=>true,
					//角色控制设置
					'class'=>'AdminWebUser',
					'stateKeyPrefix'=>'admin',//这个是设置前台session的前缀
					'loginUrl'=>array('/admin/default/login'),
				),

			), false
		);
	}

	public function beforeControllerAction($controller, $action)
	{
		if(parent::beforeControllerAction($controller, $action))
		{
			// this method is called before any module controller action is performed
			// you may place customized code here
			return true;
		}
		else
			return false;
	}
}
